package leetcode100;

public class lc052 {
    public void flatten(TreeNode root) {
        if (root==null) {
            return;
        }
        TreeNode cur = root;

        while(cur!=null) {
            if (cur.left!=null) {
                TreeNode pre = cur.left;
                while(pre.right!=null) {
                    pre = pre.right;
                }
                pre.right = cur.right;
                cur.right=cur.left;
                cur.left=null;
            }
            cur = cur.right;
        }
    }
}
